//
//  WBBPopViewViewController.m
//  UILbrary
//
//  Created by bin on 2024/11/19.
//  Copyright © 2024 mac. All rights reserved.
//

#import "WBBPopViewViewController.h"
#import <LSTPopView.h>
#import "WBBPopView.h"
#import "WBBPopAlertView.h"

@interface WBBPopViewViewController ()

@end

@implementation WBBPopViewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 添加说明文本框
    UITextView *descTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 100, self.view.frame.size.width - 40, 80)];
    descTextView.text = @"使用第三方库 LSTPopView ，实现弹窗效果， LSTPopView 支持弹窗队列管理，优先级，丰富动画效果，手势效果，指定容器，内存管理，回调事件";
    descTextView.font = [UIFont systemFontOfSize:14];
    descTextView.editable = NO;
    descTextView.backgroundColor = [UIColor systemGrayColor];
    descTextView.textColor = [UIColor whiteColor];
    [self.view addSubview:descTextView];
    
    // 创建按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(100, 200, 200, 50);
    [button setTitle:@"点击显示弹窗" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

// 按钮点击事件
- (void)buttonClicked:(UIButton *)sender {
    // 这里添加你的弹窗逻辑
    NSLog(@"按钮被点击了");
    [self showPopAlertView];
}

- (void)showPopView{
    
    WBBPopView *view = [WBBPopView new];
    LSTPopView *popview = [LSTPopView initWithCustomView:view];
    popview.hemStyle = LSTHemStyleCenter;
    LSTPopViewWK(popview);
    view.cancelCallback = ^{
        [wk_popview dismiss];
    };
    
    view.confirmCallback = ^{
        [wk_popview dismiss];
    };
    [popview pop];
    
}

- (void)showPopAlertView{
    
    WBBPopAlertView *view = [WBBPopAlertView new];
    LSTPopView *popview = [LSTPopView initWithCustomView:view];
    popview.hemStyle = LSTHemStyleCenter;
    LSTPopViewWK(popview);
    view.cancelCallback = ^{
        [wk_popview dismiss];
    };
    
    view.confirmCallback = ^{
        [wk_popview dismiss];
    };
    [popview pop];
    
}
@end
